<template>
	<public-view navType="other2" navTitle="银行卡" :showAddCard="true">
		<view class="content flex f-d-c a-i-c w-100">
			<block v-for="(item, index) in list" :key="index">
				<view class="card-box" @click="goCarInfo(item)">
					<view class="title color-fff f-s-30">
						{{item.open_bank || ""}}
					</view>
					<view class="card-ic-box flex a-i-c">
						<text class="item p-d-26">
							....
						</text>
						<text class="item p-d-26">
							....
						</text>
						<text class="item p-d-26">
							....
						</text>
						<text class="item">
							{{showCardNum(item.bank_card_number)}}
						</text>
					</view>
				</view>
			</block>
		</view>
	</public-view>
</template>

<script>
	import {goTo} from "@/nav.js"
	export default {
		data() {
			return {
				page:1,
				list:[]
			};
		},
		onShow() {
			this.getMyBankCard()
		},
		onReachBottom() {
			this.page++
			this.getMyBankCard()
		},
		methods:{
			showCardNum(num){
				let str = ""
				str = num.slice(num.length-4)
				return str
			},
			goCarInfo(item){
				goTo({url:`/pages/my/addYinhangCard?bank=${JSON.stringify(item)}`})
			},
			getMyBankCard(){
				let that = this
				that.util.getRequest({
					url:"v1/user_bank_card/index",
					data:{
						page:that.page,
						row:10
					}
				}).then(res=>{
					console.log(res)
					if(that.page === 1){
						that.list = res.data.data || []
					}else{
						if(res.data.data.length>0){
							that.list = that.list.concat(res.data.data)
						}else{
							that.page--
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.p-d-26{
		padding-bottom: 26upx;
	}
	.card-box{
		width: 694upx;
		height: 176upx;
		background: #2567F3;
		border-radius: 22upx;
		padding: 26upx 44upx;
		margin-bottom: 30upx;
		.card-ic-box{
			font-size: 48upx;
			font-weight: bold;
			color: #FFFFFF;
			.item{
				margin-right: 38upx;
			}
		}
		.title{
			margin-bottom: 14upx;
			line-height: 42upx;
		}
	}
	.content{
		padding-top: 30upx;
	}
</style>
